<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*----------Cai dat ham lay List thanh pho va Quan huyen-------------*/
class Province extends CI_Controller {
	function __construct() {
		parent::__construct ();
		$this->load->library('Form_validation');
		$this->load->model('Province_model');
		$this->load->model('Districts_model');
		$this->load->helper('url');
	}
	public function getProvinceList()
	{
		/*------------------------------------------------------------------------------*/
		$where='';
		$sidx='pre_order';
		$sord='ASC';
		$start='0';
		$limit='1000';
		$select = "pre_id, pre_name, pre_order, pre_status";
		$result = $this->Province_model->fetch($select, $where, $sidx, $sord, $start, $limit);
		$i=0;
		foreach($result as $userArray)
		{
			$responce->rows[$i]['id']=$userArray->pre_id;
			$responce->rows[$i]['name']=array($userArray->pre_name);
			$i++;
		}
		echo json_encode($responce);
	}
	public function getDistrictList()
	{
		/*------------------------------------------------------------------------------*/
		$where='';
		$sidx='id';
		$sord='ASC';
		$start='0';
		$limit='1000';
		$select = "id, dis_name, province_id";
		$result = $this->Districts_model->fetch($select, $where, $sidx, $sord, $start, $limit);
		$i=0;
		foreach($result as $userArray)
		{
			$responce->rows[$i]['id']=$userArray->id;
			$responce->rows[$i]['name']=array($userArray->dis_name);
			$responce->rows[$i]['proid']=array($userArray->province_id);
			$i++;
		}
		echo json_encode($responce);
	}
}
